package untitled;
public class Text {
    public static void main(String[] args) {
        TicketWindow tw = new TicketWindow();
        new Thread(tw,"窗口1").start();
        new Thread(tw,"窗口2").start();
        new Thread(tw,"窗口3").start();
    }
}
class TicketWindow implements Runnable{
    private int ticket = 100;
    public void run(){
        while (true){
            if(ticket>0){
                Thread thread= Thread.currentThread();
                String name = thread.getName();
                System.out.println(name+"正在卖第"+ticket--+"张票");
            }else {
                break;
            }
        }
    }
}

